/**
 * 保存证书
 * @param params
 */
function returnCertificate(params) {
    DGG.loading();
    // 验证页面字段
    if (!checkReturnCertificateFiled()) {
        DGG.loading('close');
        return false;
    }
    $.post(sysInfo.basePath + "/zs/general_credential/edit_return_certificate.do", params, function (result) {
        if (result.code == 0) {
            DGG.Succeed('证书重新入库成功');
            search('#myTable', 'reload');
            layer.closeAll();
            setTimeout(function () {
                window.parent.updateTab("证书信息列表", sysInfo.basePath + "/zs/general_credential/general_certificate_info.html?keywords=" + result.data.certificateNo);
            }, 1000);
        } else {
            DGG.Errors(result.msg);
        }
        DGG.loading('close');
    });
}


/**
 * 证书需要验证的字段
 */
function checkReturnCertificateFiled() {
    if (!$('select[name=talentPaymentMethod]').val() ) {
        DGG.Tip("请选择人才付款方式",$('select[name=talentPaymentMethod]'),{tips: [3, '#000'], time: 3000});
        return false;
    }
    if (!$('select[name=receiptType]').val() ) {
        DGG.Tip("请选择收证类型",$('select[name=receiptType]'),{tips: [3, '#000'], time: 3000});
        return false;
    } else if ($('select[name=receiptType]').val() === '0'){
        if (!checkInputBox('#channelName')) return false;
        if (!checkInputBox('#channelPhone')) return false;
        if (!checkInputBox('#channelIdCard')) return false;
    }
    if (!$('select[name=socialSecurity]').val()){
        DGG.Tip("请选择是否购买社保",$('select[name=socialSecurity]'),{tips: [3, '#000'], time: 3000});
        return false;
    }
    if ($('select[name=socialSecurity]').val() === '0' ) {
        if (!$("input[name=socialSecurityAreaChange]").val()){
            DGG.Tip("请选择社保区域",$('input[name=socialSecurityAreaChange]'),{tips: [3, '#000'], time: 3000});
            return false;
        }
    }
    // 验证下拉选择框
    if (!checkDropDownChoice('#certificateTypes', $('#certificateTypes').next(), '')) return false;
    if (!checkDropDownChoice('#certificateSpecialty', $('#certificateSpecialty').next())) return false;
    if (!checkCertificateSpecialty('#certificateTypes', '#certificateSpecialty')) return false;
    if (!checkDropDownChoice('#certificateLevels', $('#certificateLevels').next())) return false;
    if (!checkInputBox('#contractSigningTimes')) return false;

    // 验证输入框
    if (!checkInputBox('#certificateName', '请选择地区')) return false;
    if (!isFloatGteZeroByLength('#receiptPrices', 2, true, 8)) return false;
    if (!checkInputBox('#personalNames')) return false;
    if (!checkInputBox('#certificateNames')) return false;
    if (!isMobile('#personalPhones', true)) return false;
    if (!checkInputBox('#accountNames')) return false;
    if (!checkInputBox('#accountBanks')) return false;
    if (!isIdCardNo("#personalIdCards")) return false;
    if (!isWx('#personalWeixins')) return false;
    if (!regCheck(/^[0-9]\d*$/, '#accountNos', '请输入正确的银行卡号', true)) return false;
    if (!$("#certificateNo").val()) {
        DGG.Warning("证书编号不能为空");
        return false;
    }
    if (!checkCertificateNo("#certificateNo", 'GENERAL_CREDENTIAL', $('[name="id"]').val(), 0)) return false;

    return true;
}

